
//
// 110102 - AH - Created.
//

package org.soekrat.gui.swing.util;

import java.awt.Color;

import org.jgrapht.ext.JGraphModelAdapter;

/**
 * <p>
 *   Utility methods for working with the JGraph library.
 * </p>
 * @author Arne Halvorsen (AH)
 * @author Laetitia Le Chatton (LLC)
 */
public final class JGraphUtil 
{
  private JGraphUtil(){} // Utility pattern dictates private constructor.
  
  /**
   * <p>
   *   Default background color.
   * </p>
   */
  private static final Color DEFAULT_BG_COLOR=Color.decode("#FAFBFF");
  
  /**
   * <p>
   *   Position a vertex in a JGraphT graph been adapted for JGraph 
   *   visualization.  
   * </p>
   * @param <V>     Vertex type of graph.
   * @param <E>     Edge type of graph.
   * @param gm      Adapted JGraphT graph.
   * @param vertex  Vertex to position.
   * @param x       X coordinate of vertex position.
   * @param y       Y coordinate of vertex position.
   */
  @SuppressWarnings("unchecked")
  public static <V, E> void positionVertexAt(JGraphModelAdapter<V, E> gm, 
    V vertex, int x, int y)
  {
    /*
    DefaultGraphCell cell=gm.getVertexCell(vertex);
    AttributeMap attr=cell.getAttributes();
    Rectangle2D bounds=GraphConstants.getBounds(attr);

    Rectangle2D newBounds=new Rectangle2D.Double
    (
      x,
      y,
      bounds.getWidth(),
      bounds.getHeight()
    );

    GraphConstants.setBounds(attr, newBounds);

    // TODO: Clean up generics once JGraph goes generic
    AttributeMap cellAttr=new AttributeMap();
    cellAttr.put(cell, attr);
    gm.edit(cellAttr, null, null, null);
    */
  }
  
  /**
   * <p>
   *   Do some default display setting for a 
   *   JGraph.
   * </p>
   * @param jg   {@link JGraph}.
   * @param size Size of canvas.
   */
  /*
  public static void adjustDisplaySettings(JGraph jg, Dimension size)
  {
    adjustDisplaySettings(jg, size, null); 
  }
  */
  
  /**
   * <p>
   *   Do some default display setting for a 
   *   JGraph.
   * </p>
   * @param jg   {@link JGraph}.
   * @param size Size of canvas.
   * @param bg   Background color, if {@code null} do use a default color.
   */
  /*
  public static void adjustDisplaySettings(JGraph jg, Dimension size, Color bg)
  {
    jg.setPreferredSize(size);

    Color c=(bg==null) ? DEFAULT_BG_COLOR : bg;
    
    jg.setBackground(c);
  }
  */
  
}
